<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<div class="middle myclear">
	<div class="pad10">
		
		<h2 class="marbottom10 martop10">
			Danh sách Subcribe Email
		</h2>
		<hr/>
		<div class="dashboard-box myclear martop10">
			<table class="mbd-timebox " cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td class="padright10 ver-middle">
						Lọc theo trạng thái
					</td>
					<td class="padright10 ver-middle">
						<select class="payment-by-month" id="status" onchange="subcrib_filter(this.value, '<?php echo site_url('subcribe/view'); ?>');">
                            <option value="-1" <?php echo $status==-1 ? 'selected="selected"':'' ;?>>Tất cả</option>
							<option value="1" <?php echo $status==1 ? 'selected="selected"':'' ;?>>Active</option>
                            <option value="0" <?php echo $status==0 ? 'selected="selected"':'' ;?>>Unactive</option>
						</select>
					</td>
				</tr>	
			</table>
			
			<table class="tbl-list" width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td class="td-label bold text-center ver-middle" width="50">
						STT
					</td>
					
					<td class="td-label bold ver-middle">
						Email
					</td>
					
					<td class="td-label bold text-center ver-middle" width="100">
                        Trạng thái
					</td>
					
					<td class="td-label bold text-center ver-middle" width="120">
                        Created time
					</td>
					
					<td class="td-label bold text-center ver-middle" width="60">
                        ID
					</td>
				</tr>
				
				<?php
				$indexItem = 1;
				foreach($list as $item)
				{
				?>
					<tr>
						<td class="text-center pad5">
							<?php  echo $indexItem;?>
						</td>
						
						<td class="pad5">
							<?php echo $item['email']; ?>
						</td>
						
						<td class="pad5 text-center">
	                        <?php echo $item['active'] == 1 ? 'active' : 'unactive'; ?>
						</td>
						
						<td class="text-center pad5">
	                        <?php echo date('H:i:s d-m-Y', strtotime($item['create_time'])); ?>
						</td>
						
						<td class="text-center pad5">
	                        <?php echo $item['subcribe_id']; ?>
						</td>
					</tr>
				<?php
					$indexItem++;
				}
				?>
			</table>
			
			<!-- paging -->
			<?php
			if($iCount > 0)
			{
			?>
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td class="pad10 ver-middle">
							Trang
							&nbsp;
							<?php echo $cPage;?>
							/
							<?php echo $pCount;?>
						</td>
						<td class="text-right pad10 ver-middle">
							<div class="paging clear">
								<div class="paging-inner float-right">
									<?php
									if($cPage > 1)
									{
										?>
										<a href="<?php echo site_url("subcribe/view/?cpage=" . ($cPage - 1) . "&status=$status");?>">
											Trang trước
										</a>
										<?php
									}
									
									foreach($lstPaging as $artPage)
									{
										if($artPage > 0)
										{
									?>
										<a <?php echo ($artPage == $cPage) ? 'class="curr"' : '';?> href="<?php echo site_url("subcribe/view/?cpage=$artPage&status=$status");?>">
											<?php echo $artPage;?>
										</a>
									<?php
										}
									}
									
									if($cPage < $pCount)
									{
										?>
										<a href="<?php echo site_url("subcribe/view/?cpage=" . ($cPage + 1) . "&status=$status");?>">
											Trang sau
										</a>
										<?php
									}
									?>
									
								</div>
							</div>
						</td>
					</tr>
				</table>
			<?php
			} // end check paging
			?>
			<!-- end paging -->
			
		</div>
	</div>
</div>

<script type="text/javascript">
	function subcrib_filter(val, url)
	{
		window.location = url + '/?cpage=1&status=' + val;
		return;
	}
</script>